﻿
var page = {
    timer: 0,
    dateTimer: 0,
    num: 0,
    progress: 0,
    /* 此方法在第一次显示窗体前发生 */
    onLoad: function (event) {
        var that = this
        var sec = 0;
        var count = 0;
        var is_show = 1;
        var scan_count = 0;

        this.setData({
            Clock1: {
                second: { x: 0, y: 115 }
            },
            p1: { visible: false }
        })

        //默认不显示
        that.setData({ p1: { visible: false } });
        that.setData({ p2: { visible: false } });
        that.setData({ p3: { visible: false } });

        this.timer = setInterval(function () {
            that.setData({ Clock1: { value: sec++ } })

            count++;
            if (18 < count && 1 == is_show) {
                is_show = 0;
                that.setData({ p1: { visible: true } });
                that.setData({ p2: { visible: true } });
                that.setData({ p3: { visible: true } });
            }
            if (25 < count) {
                that.setData({ p1: { visible: false } });
                that.setData({ p2: { visible: false } });
                that.setData({ p3: { visible: false } });
            }
            if (60 <= count) {
                is_show = 1;
                count = 0;
            }

            if (0 == count % 60) {
                scan_count++;
                that.setData({ scan_count: { value: scan_count.toString() } });
            }

            if (that.progress > 105) {
                clearInterval(that.timer);
                pm.navigateBack('scaner_page/scaner_page')
            } else {
                that.setData({ CircleProgress1: { value: that.progress } });
            }

        }, 30)
    },

    /* 此方法展示窗体后发生 */
    onResume: function (event) {

    },

    /* 当前页状态变化为显示时触发 */
    onShow: function (event) {
        var that = this;
        this.dateTimer = setInterval(function () {
            if (that.progress > 0) {
                that.progress -= 10;
            }
        }, 650)
    },

    /* 当前页状态变化为隐藏时触发 */
    onHide: function (event) {

    },

    /* 此方法关闭窗体前发生 */
    onExit: function (event) {
        if (this.timer != 0) {
            clearInterval(this.timer);
        }

        if (this.dateTimer != 0) {
            clearInterval(this.dateTimer);
        }
    },

    btn_back: function (event) {
        this.progress += 15;
    },

};

Page(page);

page = 0;
